define(function(require, exports, module) {
    'use strict';
    
    var rk = require('rk');
    
    
    $.widget('rk.colleagueContentFollow', {
        _create:function(){
            var me = this;
            var elem = me.element;
            var opt = me.options;
            me._listeners();
        },
        _init:function(){
            var me = this;
            var elem = me.element;
            var opt = me.options;
            rk.post("/json/oa_relation/index.action",{lookedUser:opt.uid},function(json){
                if(json.status == 0) {
                    var temp = require("oa/tmpl/colleague/content/tpl_colleague_content_follow.tpl");
                    var html = rk.templateText(temp, json);
                    elem.html(html);
                    var activeTabIndex = 0;
                    if (opt.activeTabIndex) {
                        activeTabIndex = opt.activeTabIndex;
                    }
                    if (activeTabIndex == 0) {
                        me.loaddata("myFollow", elem.find("#colleague_content_my_follow"));
                    } else {
                        me.loaddata("followMe", elem.find("#colleague_content_follow_me"));
                    }
                    elem.find("[act='colleague_content_follow_tab']").tabs({
                        active: activeTabIndex,
                        activate: function (e, ui) {
                            $.proxy(me.showTabs(e, ui), me);
                        }
                    });
                }else{
                    rk.noticeError(rk.i18n('COLLEAGUE_SYSTEM_ERROR'));
                }
            });
        },
        _listeners:function(){

        },
        loaddataParam:"",
        showTabs:function(e,ui){
            var divs = ui.newPanel;
            var type = divs.attr("loadDateType");
            var me = this;
            me.loaddata(type,divs);
        },
        loaddata:function(type,divs){
            var me = this;
            var elem = me.element;
            if(type && me.loadDataJson[type]){
                $.proxy(me.loadDataJson[type].call(this,divs),me);
            }
        },
        loadDataJson:{
            "myFollow":function(divs){
                var me = this;
                var elem = me.element;
                var opt = me.options;
                divs.beLoading();
                require.async(["./colleagueContentMyFollow"],function(){
                    divs.colleagueContentMyFollow({uid:opt.uid});
                });
            },
            "followMe":function(divs){
                var me = this;
                var elem = me.element;
                var opt = me.options;
                //alert("我的粉丝")
                divs.beLoading();
                require.async(["./colleagueContentFollowMe"],function(){
                    divs.colleagueContentFollowMe({uid:opt.uid});
                });
            }
        }
    });
});